package com.y3k.model
{
	import com.y3k.mail.MailConfiguration;
	
	import mx.collections.ArrayCollection;
	import mx.utils.StringUtil;
	
	public class Session
	{
		public static var user:User;

		public static var path:String;

		public static var ipcontrol:Boolean;

		public static var filters:ArrayCollection = new ArrayCollection();

		public static var datasources:ArrayCollection = new ArrayCollection();

		public static var configuration:Configuration = new Configuration;
		
		public static var notifications:ArrayCollection = new ArrayCollection();

		public static var mail:MailConfiguration = new MailConfiguration();

		public function Session()
		{
		}

		public static function existProfile(profiles:String):Boolean {			
			var profilesArray:Array = profiles.split(",");
						
			for each(var userProfiles:String in user.profiles) {
				for each(var tabProfile:String in profilesArray) {
					if(StringUtil.trim(tabProfile) == StringUtil.trim(userProfiles)) {
						return true;
					}
				}
			}
			return false;
		}
		
		public static function filter(filter:String):void {
			var data:Array = filter.split(";");
			
			for each (var item:Filter in filters) {				
				if(item.filterName == data[0]) {
					item.selected = data[1];
				}
			} 
		}
		
		public static function cleanFilter(filterName:String):void {
			for each (var item:Filter in filters) {				
				if(item.filterName == filterName) {
					item.selected = "";
				}
			}
		}
	}
}